$gwx_XC_31=function(_,_v,_n,_p,_s,_wp,_wl,$gwn,$gwl,$gwh,wh,$gstack,$gwrt,gra,grb,TestTest,wfor,_ca,_da,_r,_rz,_o,_oz,_1,_1z,_2,_2z,_m,_mz,nv_getDate,nv_getRegExp,nv_console,nv_parseInt,nv_parseFloat,nv_isNaN,nv_isFinite,nv_decodeURI,nv_decodeURIComponent,nv_encodeURI,nv_encodeURIComponent,$gdc,nv_JSON,_af,_gv,_ai,_grp,_gd,_gapi,$ixc,_ic,_w,_ev,_tsd){return function(path,global){
if(typeof global==='undefined'){if (typeof __GWX_GLOBAL__==='undefined')global={};else global=__GWX_GLOBAL__;}if(typeof __WXML_GLOBAL__ === 'undefined') {__WXML_GLOBAL__={};
}__WXML_GLOBAL__.modules = __WXML_GLOBAL__.modules || {};
var e_={}
if(typeof(global.entrys)==='undefined')global.entrys={};e_=global.entrys;
var d_={}
if(typeof(global.defines)==='undefined')global.defines={};d_=global.defines;
var f_={}
if(typeof(global.modules)==='undefined')global.modules={};f_=global.modules || {};
var p_={}
__WXML_GLOBAL__.ops_cached = __WXML_GLOBAL__.ops_cached || {}
__WXML_GLOBAL__.ops_set = __WXML_GLOBAL__.ops_set || {};
__WXML_GLOBAL__.ops_init = __WXML_GLOBAL__.ops_init || {};
var z=__WXML_GLOBAL__.ops_set.$gwx_XC_31 || [];
function gz$gwx_XC_31_1(){
if( __WXML_GLOBAL__.ops_cached.$gwx_XC_31_1)return __WXML_GLOBAL__.ops_cached.$gwx_XC_31_1
__WXML_GLOBAL__.ops_cached.$gwx_XC_31_1=[];
(function(z){var a=11;function Z(ops){z.push(ops)}
Z([[7],[3,'animated']])
Z([1,true])
Z([[7],[3,'background']])
Z([[7],[3,'color']])
Z([[7],[3,'show']])
Z([[7],[3,'title']])
Z([3,'openArking'])
Z([[2,'=='],[[7],[3,'openStatus']],[1,1]])
Z([[2,'=='],[[7],[3,'openStatus']],[1,2]])
Z([[2,'=='],[[7],[3,'openStatus']],[1,3]])
Z([[2,'=='],[[7],[3,'openStatus']],[1,4]])
Z([3,'mode_arks'])
Z([[7],[3,'can_optin']])
Z([[2,'=='],[[7],[3,'model']],[1,4]])
Z([[2,'=='],[[7],[3,'openBox']],[1,13]])
Z([[2,'=='],[[7],[3,'model']],[1,3]])
Z(z[14])
Z([[2,'=='],[[7],[3,'model']],[1,2]])
Z(z[14])
Z([[2,'=='],[[7],[3,'model']],[1,1]])
Z(z[14])
Z([[2,'!'],[[7],[3,'can_optin']]])
Z(z[12])
Z([3,'wating_btn'])
Z([[2,'!='],[[7],[3,'mainboard_type']],[1,3]])
Z([[2,'&&'],[[2,'&&'],[[2,'!='],[[7],[3,'openStatus']],[1,2]],[[2,'=='],[[7],[3,'noagain']],[1,false]]],[[2,'!='],[[7],[3,'openBox']],[1,13]]])
Z(z[25])
Z([[2,'=='],[[7],[3,'openStatus']],[1,2]])
Z([[2,'&&'],[[7],[3,'can_optin']],[[2,'=='],[[7],[3,'openStatus']],[1,2]]])
Z(z[12])
Z([[7],[3,'showPop']])
Z([[7],[3,'isBannerPop']])
})(__WXML_GLOBAL__.ops_cached.$gwx_XC_31_1);return __WXML_GLOBAL__.ops_cached.$gwx_XC_31_1
}
__WXML_GLOBAL__.ops_set.$gwx_XC_31=z;
__WXML_GLOBAL__.ops_init.$gwx_XC_31=true;
var x=['./pages/openArking/openArking.wxml'];d_[x[0]]={}
var m0=function(e,s,r,gg){
var z=gz$gwx_XC_31_1()
var o4I=_mz(z,'navigation-bar',['animated',0,'back',1,'background',1,'color',2,'show',3,'title',4],[],e,s,gg)
_(r,o4I)
var l5I=_n('view')
_rz(z,l5I,'class',6,e,s,gg)
var a6I=_v()
_(l5I,a6I)
if(_oz(z,7,e,s,gg)){a6I.wxVkey=1
}
var t7I=_v()
_(l5I,t7I)
if(_oz(z,8,e,s,gg)){t7I.wxVkey=1
}
var e8I=_v()
_(l5I,e8I)
if(_oz(z,9,e,s,gg)){e8I.wxVkey=1
}
var b9I=_v()
_(l5I,b9I)
if(_o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)
if(_oz(z,26,e,s,gg)){cRJ.wxVkey=1
}
cRJ.wxXCkey=1
}
var oPJ=_v()
_(oNJ,oPJ)
if(_oz(z,27,e,s,gg)){oPJ.wxVkey=1
}
xOJ.wxXCkey=1
oPJ.wxXCkey=1
_(o0I,oNJ)
}
var xAJ=_v()
_(l5I,xAJ)
if(_oz(z,28,e,s,gg)){xAJ.wxVkey=1
}
var oBJ=_v()
_(l5I,oBJ)
if(_oz(z,29,e,s,gg)){oBJ.wxVkey=1
}
a6I.wxXCkey=1
t7I.wxXCkey=1
e8I.wxXCkey=1
b9I.wxXCkey=1
o0I.wxXCkey=1
xAJ.wxXCkey=1
oBJ.wxXCkey=1
_(r,l5I)
var o2I=_v()
_(r,o2I)
if(_oz(z,30,e,s,gg)){o2I.wxVkey=1
}
var c3I=_v()
_(r,c3I)
if(_oz(z,31,e,s,gg)){c3I.wxVkey=1
}
o2I.wxXCkey=1
c3I.wxXCkey=1
return r
}
e_[x[0]]=e_[x[0]]||{f:m0,j:[],i:[],ti:[],ic:[]}
if(path&&e_[path]){
return function(env,dd,global){$gwxc=0;var root={"tag":"wx-page"};root.children=[]
;g="$gwx_XC_31";var main=e_[path].f
if (typeof global==="undefined")global={};global.f=$gdc(f_[path],"",1);
try{
main(env,{},root,global);
_tsd(root)
}catch(err){
console.log(err)
}
;g="";
return root;
}
}
}
}(__g.a,__g.b,__g.c,__g.d,__g.e,__g.f,__g.g,__g.h,__g.i,__g.j,__g.k,__g.l,__g.m,__g.n,__g.o,__g.p,__g.q,__g.r,__g.s,__g.t,__g.u,__g.v,__g.w,__g.x,__g.y,__g.z,__g.A,__g.B,__g.C,__g.D,__g.E,__g.F,__g.G,__g.H,__g.I,__g.J,__g.K,__g.L,__g.M,__g.N,__g.O,__g.P,__g.Q,__g.R,__g.S,__g.T,__g.U,__g.V,__g.W,__g.X,__g.Y,__g.Z,__g.aa);if(__vd_version_info__.delayedGwx||false)$gwx_XC_31();	if (__vd_version_info__.delayedGwx) __wxAppCode__['pages/openArking/openArking.wxml'] = [$gwx_XC_31, './pages/openArking/openArking.wxml'];else __wxAppCode__['pages/openArking/openArking.wxml'] = $gwx_XC_31( './pages/openArking/openArking.wxml' );
	;__wxRoute = "pages/openArking/openArking";__wxRouteBegin = true;__wxAppCurrentFile__="pages/openArking/openArking.js";define("pages/openArking/openArking.js",function(require,module,exports,window,document,frames,self,location,navigator,localStorage,history,Caches,screen,alert,confirm,prompt,XMLHttpRequest,WebSocket,Reporter,webkit,WeixinJSCore){
"use strict";var e,t,a=require("../../@babel/runtime/helpers/interopRequireDefault")(require("../../@babel/runtime/regenerator")),n=require("../../@babel/runtime/helpers/asyncToGenerator"),r=require("../../@babel/runtime/helpers/defineProperty"),o=require("../../miniprogram_npm/btls/index"),i=getApp(),s=require("../../env.js"),u=require("../../utils/util.js"),c="",d="",l="";Page({data:(e={bluestatus:"",title:"开柜",color:"#FFFFFF",background:"#FCBC88",show:!0,animated:!1,o_backs:!1,order_id:"",blue_res:"",mainboard_type:"",device_id:"",model:1,openStatus:1,openBox:0,currentTime:15,noagain:!1,can_optin:!1,phoneConfig:"",system:"",autoplay:!0,bannerArr:[]},r(e,"phoneConfig",""),r(e,"is_uuid",null),r(e,"device_no",null),r(e,"blueNextSendTime",5),r(e,"isOnUnload",!1),r(e,"showPop",!1),e),onLoad:(t=n(a.default.mark((function e(t){var n,r,o,i,s,u,c;return a.default.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if((n=wx.getStorageSync("phoneConfig"))||this.getPhoneConfig(),r=t.order_id,o=t.o_backs,i=t.blue_res,s=t.mainboard_type,u=t.openBox,c=t.model,this.setData({phoneConfig:n,bluestatus:wx.getStorageSync("bluestatus"),connectStatus:wx.getStorageSync("connectStatus"),o_backs:/true/.test(o),order_id:r,mainboard_type:s,blue_res:i||null,openBox:u,model:c}),this.getBannerLists(),this.getDeviceInfo(),null===i||3!=s){e.next=8;break}return e.abrupt("return",this.checkBlueRes());case 8:this.setData({openStatus:4});case 9:case"end":return e.stop()}}),e,this)}))),function(e){return t.apply(this,arguments)}),onShow:function(){3==this.data.mainboard_type&&i.reconnectBlue()},onUnload:function(){clearInterval(c),clearInterval(l),this.setData({isOnUnload:!0})},myOrder:function(){wx.redirectTo({url:"../myOrder/myOrder"})},goHome:function(){wx.switchTab({url:"/pages/home/home"})},backup:function(){wx.navigateBack({delta:1})},closeActivity:function(){this.setData({showPop:!1})},getPhoneConfig:function(){var e=this;i.ajax({url:"common/Common/getConfig",data:{key:"web_config.CustomerPhone"},success:function(t){1e3==t.data.code&&e.setData({phoneConfig:t.data.data})}})},goCallPhone:function(e){var t=e.currentTarget.dataset.phone;wx.makePhoneCall({phoneNumber:t})},initBule:function(e,t,a){this.setData({openStatus:4});var n=new o.BLE({mainboard_no:e,device_no:t,isSaveBlueLog:!0,env:s,isUuid:a,isGlobal:!0});i.globalData.blue=n,s.isDev||(i.globalData.blue.init(),this.watchBLE())},watchBLE:function(){var e=this,t=this.data,a=t.mainboard_type,n=t.two_order,r=i.globalData.blue;s.isDev||r&&3==a&&r.watchListen((function(t){if(console.log(t),"connect"==t.type)"订阅特征值成功"==t.data&&2!=e.data.openStatus&&e.getDeviceCode(),"蓝牙已断开"==t.data&&e.setData({bluestatus:!1,openStatus:4}),"蓝牙已连接"==t.data&&2!=e.data.openStatus&&e.setData({bluestatus:!0,openStatus:1});else if("response"==t.type){if(e.openArkFunSuc(),e.bluetoothCallOpenDoor(),e.setData({openStatus:2}),2!==n)return;e.setData({showPop:!0}),wx.vibrateLong()}}))},getDeviceInfo:function(){var e=this,t=this.data,a=t.order_id,n=t.blue_res,r={order_id:a,time:Math.random()},o=u.encryption(JSON.stringify(r));this.setData({sys_encrypt_data:o}),i.ajax({url:"User/Order/deviceInfo",data:{sys_encrypt_data:o},success:function(t){if(1e3==t.data.code){var a=t.data.data,r=a.device_model,o=a.device_id,s=a.device_no,u=a.door_number,l=a.mainboard_type_id,p=a.two_order,h=a.pay_state,f=a.is_uuid,g=t.data,_=g.data,b=g.sign_data;if(1==h){if(e.setData({model:r,device_no:s,device_id:o,openBox:u,mainboard_type:l,two_order:p,is_uuid:f,infoData:_,sign_data:b}),d=t.data.data.mainboard_no,3!==l)return clearInterval(c),c=setInterval((function(){e.queryOpenSate()}),1200),void e.openArkFun();if(n){if(2!==p)return;e.setData({showPop:!0}),wx.vibrateLong()}var v=wx.getStorageSync("connectStatus"),m=wx.getStorageSync("bluestatus"),w=0==n||null==n;console.log(v&&w),v&&w&&(e.watchBLE(),0!==n&&e.getDeviceCode()),m||e.initBule(d,s,f)}else i.showToast("该订单未完成，请购买哦~"),setTimeout((function(){wx.navigateBack({delta:1})}),2e3)}else e.resultErr(),i.showToast(t.data.msg)}})},resultErr:function(){this.setData({openStatus:3,can_optin:!0})},checkBlueRes:function(){var e=this.data.blue_res;1==e?this.setData({can_optin:!0,openStatus:2}):0==e&&this.resultErr()},getDeviceCode:function(){var e=this;return n(a.default.mark((function t(){var n,r,o,s,c,l,p,h,f,g,_,b;return a.default.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:if(n=e.data,r=n.infoData,o=n.sign_data,s=n.sys_encrypt_data,!n.isOnUnload){t.next=3;break}return t.abrupt("return");case 3:if(c=i.globalData.blue.device_no,l=c==r.device_no,p=JSON.parse(JSON.stringify(o)),h=s==o.sys_encrypt_data,u.checkSign(r,p,o.sign)&&h&&l){t.next=11;break}return i.showToast("开门数据错误"),t.abrupt("return");case 11:if(f=e.data,g=f.openBox,_=f.blue_res,b=i.globalData.blue,!g.toString()){t.next=25;break}if(e.setData({openStatus:1}),b.mainboard_no===d||null!=_){t.next=19;break}return e.resultErr(),i.showToast("未连接该设备"),t.abrupt("return");case 19:return t.next=21,b.send(g.toString());case 21:t.sent||e.setData({openStatus:3}),t.next=26;break;case 25:i.showToast("此货柜无法开启，请重试，或联系管理员");case 26:case"end":return t.stop()}}),t)})))()},openArkFun:function(){var e=this;this.setData({currentTime:15,can_optin:!1,openStatus:1}),l=setInterval((function(){var t=e.data.currentTime;t--,e.setData({currentTime:t}),t<=0&&(clearInterval(l),clearInterval(c),e.setData({currentTime:0,can_optin:!0}))}),1e3)},queryOpenSate:function(){var e=this,t=this.data,a=t.device_id,n=t.order_id;i.ajax({url:"User/Order/queryDoor",data:{device_id:a,order_id:n,mainboard_no:d},success:function(t){1e3==t.data.code?(1!=t.data.data.state&&(clearInterval(c),2==t.data.data.state?(e.setData({can_optin:!0}),wx.setStorageSync("can_query",!1)):e.setData({can_optin:!0})),e.setData({openStatus:t.data.data.state})):-1003==t.data.code?(clearInterval(c),e.setData({noagain:!0,can_optin:!0}),i.showToast(t.data.msg)):i.showToast(t.data.msg)}})},openAgain:function(){var e=this;if(13==this.data.openBox)return i.showToast("货道不支持再次开柜,如有问题请联系客服"),!1;i.ajax({url:"User/Order/againOpenDoor",data:{order_id:this.data.order_id},success:function(e){}}),c=setInterval((function(){e.queryOpenSate()}),1200),this.openArkFun()},reloadOpen:u.debounce((function(){this.openAgainBlue()}),1e3),openAgainBlue:function(){var e=this,t=this.data,a=t.order_id,n=t.bluestatus;i.ajax({url:"User/Order/deviceInfo",data:{order_id:a},success:function(t){if(1e3==t.data.code){var a=i.globalData.blue.checkRoot().root,r=wx.getStorageSync("connectStatus").connectStatus;if(n&&!a)return void i.showToast("连接丢了，请打开蓝牙与GPS重试");if(r)return void i.showToast("蓝牙未连接");e.blueNextSendTime(),e.getDeviceCode()}else i.showToast(t.data.msg)}})},blueNextSendTime:function(){var e=this,t=this.data.blueNextSendTime,a=setInterval((function(){t--,0==t&&(clearInterval(a),t=5),e.setData({blueNextSendTime:t})}),1e3)},openArkFunSuc:function(){clearInterval(l),clearInterval(c),this.setData({currentTime:0,can_optin:!0,openStatus:2})},bluetoothCallOpenDoor:function(){var e=this.data.order_id;i.ajax({url:"User/Order/bluetoothCallOpenDoor",data:{order_id:e,type:2},success:function(e){}})},swiperChange:function(e){this.setData({inDots:e.detail.current})},getBannerLists:function(){var e=this,t=this.data.is_android;i.ajax({url:"api/Ad/getLists",data:{page:1,limit:100,search:{title:"",goods_cate_id:"",column_code:"AKzWkT4c"}},success:function(a){if(1e3==a.data.code){var n=a.data.data,r=[];n.forEach((function(e){t&&1==e.an_show&&r.push(e),t||1!=e.ios_show||r.push(e)})),e.setData({bannerArr:r})}}})},getPhoneNumber:function(e){var t=this;return n(a.default.mark((function n(){var r,o;return a.default.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return r=e.detail,o=e.currentTarget.dataset.item,a.next=4,t.getBannerAdRecord(o.id);case 4:wx.login({success:function(a){i.ajax({url:"admin/api.card.index/getUserInfo",data:{code:a.code},success:function(a){if(0==a.data.code&&"getPhoneNumber:ok"==r.errMsg){var n={identity:4,session_key:a.data.data.session_key,data:r.encryptedData,iv:r.iv};t.getDecryptPhone(n,e)}}})}});case 5:case"end":return a.stop()}}),n)})))()},goBanner:function(e){var t=this;return n(a.default.mark((function n(){var r,o,i,s,u,c,d,l,p,h,f,g,_,b;return a.default.wrap((function(a){for(;;)switch(a.prev=a.next){case 0:return r=e.currentTarget.dataset.item,a.next=3,t.getBannerAdRecord(r.id);case 3:if(o=t.data.phoneConfig,i=r.link_type,s=r.link,u=r.is_tab,c=r.is_popup,d=r.popup_title,l=r.is_tel,p=r.is_phone,h=r.id,f=r.ad_lists_user_id,g=r.other_weapp_appid,_=wx.getStorageSync("phone")||"",!l){a.next=9;break}return wx.makePhoneCall({phoneNumber:o}),a.abrupt("return");case 9:c?t.setData({popup_title:d,isBannerPop:!0}):1==i?1==u?wx.switchTab({url:s}):wx.navigateTo({url:s}):2==i?(b={link:s},1==p&&(b.phone=_,b.id=h,b.ad_lists_user_id=f,b.openid=wx.getStorageSync("openid")),wx.navigateTo({url:"../webView/webView?link="+JSON.stringify(b)})):3==i&&wx.navigateToMiniProgram({appId:g,path:s});case 10:case"end":return a.stop()}}),n)})))()},getDecryptPhone:function(e,t){var a=this;t.currentTarget.dataset.item;i.ajax({url:"api/Wx/aesPhoneDecrypt",data:e,success:function(e){1e3==e.data.code?(wx.setStorageSync("phone",e.data.data.phoneNumber),a.goBanner(t)):i.showToast(e.data.msg+"请重新授权")}})},getBannerAdRecord:function(e){i.ajax({url:"user/user/bannerAdRecord",data:{ad_id:e},success:function(e){1e3!=e.data.code&&i.showToast(e.msg)}})},colseBannerPop:function(){this.setData({isBannerPop:!1})}});
},{isPage:true,isComponent:true,currentFile:'pages/openArking/openArking.js'});require("pages/openArking/openArking.js");